#include<bits/stdc++.h>

using namespace std;
using ll = long long;
#define endl '\n'
struct Edge {
    int x, y;
} E[5] = {
        {1, 2},
        {1, 3},
        {1, 4},
        {2, 4},
        {4, 5}

};
int Vertex[5] = {1, 2, 3, 4, 5};
int n = 5, m = 5;
int book[6];

void dfs(int x) {
    if (book[x])return;
    cout << x << " ";
    book[x] = 1;
    for (auto e:E) {
        if (e.x == x) {
            if (book[e.y])continue;
            dfs(e.y);
        }
    }
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

    dfs(1);


    return 0;
}
